<template>
	<div class=" projectDialog">
		<el-dialog title="编辑" :visible.sync="dialogVisible" center>
			<el-form ref="form" :rules="rules" :model="data" label-width="100px" label-position="right">
				<el-form-item label="内容" prop="content">
					<el-input v-model="data.content" type="textarea" style="width:360px"></el-input>
				</el-form-item>

				<el-form-item style="margin-top: 30px">
					<el-button style="width:120px" type="primary" @click="OnSubmit">保存</el-button>
					<el-button style="width:120px" @click="Hiden">取消</el-button>
				</el-form-item>
			</el-form>
		</el-dialog>
	</div>
</template>
<script>
	export default {
		components: {},
		mounted() {},
		props: ['showDialogId', 'operateType','editData'],
		data() {
			return {
				dialogVisible: true,
				data: {},
				rules: {
					content: [{
						required: true,
						message: '请输入内容',
						trigger: 'blur'
					}]
				},
				initData: {}
			}
		},
		methods: {
			OnSubmit() {
				this.$refs['form'].validate((valid) => {
					if(valid) {
						var url = "";
						if(!this.data.id) {
							switch(this.operateType) {
								case 0:
									url = 'tProjectProgress/addProjectProgress';
									break;
								case 1:
									url = 'tProjectProblem/addProjectProblem';
									break;
								case 2:
									url = 'tProjectMeasures/addProjectMeasures';
									break;
							}
						} else {
							switch(this.operateType) {
								case 0:
									url = 'tProjectProgress/editProjectProgress';
									break;
								case 1:
									url = 'tProjectProblem/editProjectProblem';
									break;
								case 2:
									url = 'tProjectMeasures/editProjectMeasures';
									break;
							}
						}
						this.data.pId=this.showDialogId;
						this.data.status=1;
						this.data.isDelete=1;
						this.data.examineState=1;
						this.ajax({
							url: url,
							type: 'post',
							data: this.data,
							success: function(data) {
								this.Hiden();
								this.$parent.Refresh();
							}
						});
					} else {
						return false;
					}
				});
			},
			Hiden() {
				this.dialogVisible = false;
			},
			ClearData() {
				this.$refs['form'].resetFields();
				this.data = JSON.parse(JSON.stringify(this.initData));
			}
		},
		watch: {
			dialogVisible(val) {
				this.$emit('update:showDialog', val)
			},
			editData: function(newVal, oldVal) {
				this.data = newVal;
			}
		},
	}
</script>
<style lang="less">
	.streetEdit .el-form-item__error {
		top: 35px;
		left: 100px;
	}
	
	.streetEdit .el-form-item {
		min-height: 50px;
		margin-bottom: 5px;
	}
</style>
<style scoped lang="less">
	.zui-noFloat .el-col {
		float: none;
		display: inline-block;
		margin-right: -4px;
		vertical-align: top;
	}
	
	.projectDialog .desc-input {
		width: 70%;
		float: left;
	}
	
	.el-dialog--small {
		min-width: 400px !important;
		min-height: 300px !important;
	}
</style>